Zeroing Memory at Allocation
The memory allocated by malloc or similar C-Runtime functions is not initialized to zero according to the C99 specification, which Windows follows. To maintain backwards compatibility, RTX64 provides a Zero memory on allocation setting in the Control Panel.
For backwards compatibility, this setting is enabled by default. When this setting is disabled, memory requests from some C-Runtime functions or RTAPIs will not be initialized to zero at allocation. However, by definition, memory requests from calloc/_recalloc, VirtualAlloc, and HeapAlloc/HeapReAlloc with the HEAP_ZERO_MEMORY flag will be initialized to zero at allocation.
NOTE: In RTX64 3.x and earlier, RTX64 always zeroed memory.
NOTE: To improve performance, you should disable this setting once you are sure your processes do not depend on zero memory.
The table below lists the initialization status of the returning memory from various C-Runtime functions and RTAPIs:
Functions | Zero Memory At Allocation disabled | Zero Memory At Allocation enabled |
---|---|---|
malloc/new/realloc/_expand | Not zeroed | Zeroed (RTSSRelease configuration only) |
calloc/_recalloc | Zeroed | Zeroed |
RtAllocateLocalMemory | Not zeroed | Zeroed |
RtAllocateLocalMemoryEx without RTALLOC_NOT_ZERO_MEMORY flag | Not zeroed | Zeroed |
RtAllocateLocalMemoryEx with RTALLOC_NOT_ZERO_MEMORY flag | Not zeroed | Not zeroed |
HeapAlloc/HeapReAlloc without HEAP_ZERO_MEMORY | Not zeroed | Zeroed |
HeapAlloc/HeapReAlloc with HEAP_ZERO_MEMORY | Zeroed | Zeroed |
VirtualAlloc | Zeroed | Zeroed |
RtAllocateLockedMmeory | Not zeroed | Zeroed |
RtCreateSharedMemory | Not zeroed | Zeroed |
NOTE: The behavior of initializing memory to zero at allocation is the same whether you use local memory or Windows memory.